$(function () {
    let regi_validform = $('.regi_check').Validform({
        tiptype:3
    })
    let register = {
        url: {
            regiUrl: 'front/register'
        },
        init: function () {
            let _self = register
            // 地区级联初始化
            $('#area').citySelect({prov:"浙江", city:"杭州", dist:"上城区"})
            // 注册
            $('#registerBtn').on('click', () => {
                _self.toRegister()
            })
        },
        toRegister: () => {
            let _self = register
            if (!regi_validform.check(false)) { return }
            let form = $('.regi_check')
            let param = {
                userName: $.trim(form.find('input[name=userName]').val()),
                pwd: $.trim(form.find('input[name=pwd]').val()),
                contactTel:  $.trim(form.find('input[name=contactTel]').val()),
                companyName:  $.trim(form.find('input[name=companyName]').val()),
                province: form.find('select[name=province]').val(),
                city: form.find('select[name=city]').val(),
                area: form.find('select[name=area]').val(),
                companyAddress:  $.trim(form.find('input[name=companyAddress]').val()),
            }
            $.post(_self.url.regiUrl, param, (data) => {
                if (data.success) {
                    $('#regi_result').show().find('.msg').html(data.msg)
                    $('#regi_form').hide()
                } else {
                    alert(data.msg)
                }
            })
        }
    }
    register.init()
})